/*
 * @Author: 菜单页面
 * @Date: 2020-05-21 09:21:48
 * @LastEditTime: 2020-05-25 11:44:55
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \jump\assets\script\menu\MenuScene.ts
 */ 

import { G } from "../G";

const {ccclass, property} = cc._decorator;

@ccclass
export class MenuScene extends cc.Component {

    @property(cc.Node)
    private startButton: cc.Node = null;
    @property(cc.Node)
    private loadingNode: cc.Node = null;
    @property(cc.Label)
    private loadingLabel: cc.Label = null;
    
    onLoad () {
        // 适配
        if (cc.sys.isMobile) {
            cc.find("Canvas").getComponent(cc.Canvas).fitHeight = false;
            cc.find("Canvas").getComponent(cc.Canvas).fitWidth = true;
        }
    }

    start () {
        // 开始游戏 按钮添加 监听事件
        this.addListeners();
    }
 
    onBtnStart() {
        this.loadingNode.active = true;

        // 切换 game 场景
        G.startGame();
    }

    addListeners () {
        this.startButton.on(cc.Node.EventType.TOUCH_END, this.onBtnStart, this);
    }
}